package com.neuedu.autosale.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.autosale.entity.Emp;
import com.neuedu.autosale.entity.Pager;
import com.neuedu.autosale.entity.Result;
import com.neuedu.autosale.mapper.EmpMapper;
import com.neuedu.autosale.sys.service.EmpService;

@Service
@Transactional
public class EmpServiceImpl implements EmpService {
	@Autowired
	private EmpMapper empMapper;

	@Override
	public List<Emp> findListByPager(Pager<Emp> pager) {
		return empMapper.findListBypager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Emp> pager) {
		return empMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Emp object) {
		Result result = new Result(false, "新增失败！");
		boolean ret = empMapper.add(object);
		if (ret) {
			result = new Result(true, "新增成功！");
		}
		return result;
	}

	@Override
	public Result edit(Emp object) {
		Result result = new Result(false, "修改失败！");
		boolean ret = empMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Emp> ids) {
		Result result = new Result(false, "删除失败！");
		boolean ret = empMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除成功！");
		}
		return result;
	}

	@Override
	public List<Emp> findAll() {
		return empMapper.findAll();
	}

	@Override
	public Emp login(Emp emp) {
		return empMapper.login(emp);
	}

}
